package bb.lanxing.devices.sync;

import bb.lanxing.manager.SharedManager;
import org.json.JSONException;
import org.json.JSONObject;

public class IgpsManager {
    private static final String KEY_IGPS_INFOMATION = "key_igps_infomation";
    private int age;
    private String expires;
    private int height;
    private int memberID;
    private String nickName;
    private String sex;
    private String token;
    private int weight;

    public static void update(String str) {
        SharedManager.getInstance().setValue(KEY_IGPS_INFOMATION, str);
    }

    private void readFromJson() {
        String string = SharedManager.getInstance().getString(KEY_IGPS_INFOMATION, null);
        if (string == null) {
            return;
        }
        try {
            JSONObject jSONObject = new JSONObject(string);
            this.memberID = jSONObject.getInt("MemberID");
            this.nickName = jSONObject.getString("NickName");
            this.sex = jSONObject.getString("Sex");
            this.age = jSONObject.getInt("Age");
            this.weight = jSONObject.getInt("Weight");
            this.height = jSONObject.getInt("Height");
            this.token = jSONObject.getString("Token");
            this.expires = jSONObject.getString(/*OpenStreetMapTileProviderConstants.HTTP_EXPIRES_HEADER*/"Expires");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public IgpsManager() {
        readFromJson();
    }

    public int getMemberID() {
        return this.memberID;
    }

    public int getAge() {
        return this.age;
    }

    public int getWeight() {
        return this.weight;
    }

    public int getHeight() {
        return this.height;
    }

    public String getToken() {
        return this.token;
    }

    public static void unbind() {
        SharedManager.getInstance().setValue(KEY_IGPS_INFOMATION, "");
    }
}
